package net.skyaims.test;

import net.skyaims.aiolia.chat.BootStrap;
import net.skyaims.aiolia.chat.http.HttpEnvironment;
import net.skyaims.aiolia.chat.http.HttpOption;
import net.skyaims.aiolia.chat.http.HttpServer;
import net.skyaims.aiolia.chat.litp.LitpDock;
import net.skyaims.aiolia.chat.litp.LitpEnvironment;
import net.skyaims.aiolia.chat.litp.LitpOption;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MyServer {

    private static final Logger log = LoggerFactory.getLogger(MyServer.class);

    public static void main(String[] args) {

        System.out.println((1 << 8) + 1);
        System.out.println((1 << 8) + 2);

        boolean http = false;
        boolean litp = true;

        if (http) {

            BootStrap.launch(new HttpServer() {

                @Override
                public void startup(HttpOption option) throws Exception {
                    // TODO Auto-generated method stub
                    option.setPort(8080);
                    log.info("----- http server startup -----");
                }

                @Override
                public void initialize(HttpEnvironment env) throws Exception {
                    // TODO Auto-generated method stub
                    env.addResource(UserResource.class);
                }

                @Override
                public void shutdown() throws Exception {
                    // TODO Auto-generated method stub
                    log.info("----- http server shutdown -----");
                }

            });
        }

        if (litp) {

            //MessageProcessorFactory.register(MessageType.MESSAGE_TYPE_LOGIN_RECE,);

            BootStrap.launch(new LitpDock() {

                @Override
                public void startup(LitpOption opt) throws Exception {
                    // TODO Auto-generated method stub
                    opt.setPort(8081);
                    log.info("----- litp server startup -----");
                }

                @Override
                public void shutdown() throws Exception {
                    // TODO Auto-generated method stub
                    log.info("----- litp server shutdown -----");
                }

                @Override
                public void initialize(LitpEnvironment env) throws Exception {
                    // TODO Auto-generated method stub

                }
            });

        }

    }

}
